<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateMenuTbl extends Migrator
{
    const TBL_NAME = 'menu';

    public function change()
    {
        // create the table
        $table  =  $this->table(addTablePrefix(self::TBL_NAME),[
            'engine'=>'InnoDB',
            'comment' => '菜单表',
            'signed' => false
        ]);
        $table
            ->addColumn('name', 'string',array('limit'=>17,'default'=>'','comment'=>'菜单名称'))
            ->addColumn('route', 'string',array('limit'=>32, 'default'=>'','comment'=>'菜单路由'))
            ->addColumn('icon',  'string',array('limit'=>12, 'default'=>'', 'comment'=>'菜单图标'))
            ->addColumn('sort', 'integer',array('signed'=>false,'default'=>0,'comment'=>'排序'))
            ->addColumn('parent_id', 'integer',array('signed'=>false,'default'=>0,'comment'=>'父菜单ID'))
            ->addColumn('type', 'integer',array('signed'=>false,'default'=>1,'comment'=>'类型(1为前端,2为后端)'))
            ->addColumn('create_time', 'integer',array('default'=>0,'comment'=>'创建时间'))
            ->addColumn('update_time', 'integer',array('default'=>0,'comment'=>'更新时间'))
            ->addIndex(array('name'), array('unique'  =>  true))
            ->create();
    }
}
